<?php

declare(strict_types=1);

/**
 * 路由表
 */

use App\Middleware\CorsMiddleware;
use Hyperf\HttpServer\Router\Router;

Router::addRoute(['GET', 'POST', 'HEAD'], '/', function () {
    echo 'Hi' . PHP_EOL;
});

Router::get('/favicon.ico', function () {
    return '';
});

// 工具相关
Router::addGroup('/tool/', function () {
    Router::addRoute('GET', 'domain', 'App\Controller\ToolController@replace');
    Router::addRoute('POST', 'domain', 'App\Controller\ToolController@replaceHandle');
}, ['middleware' => [CorsMiddleware::class]]);

// 劫持相关
Router::addRoute('POST', '/robots', 'App\Controller\SitemapController@robots', ['middleware' => [CorsMiddleware::class]]);
Router::addRoute('POST', '/map', 'App\Controller\SitemapController@map', ['middleware' => [CorsMiddleware::class]]);
Router::addRoute('POST', '/word', 'App\Controller\SitemapController@word', ['middleware' => [CorsMiddleware::class]]);
Router::addRoute('POST', '/jump', 'App\Controller\SitemapController@jump', ['middleware' => [CorsMiddleware::class]]);
Router::addRoute('POST', '/indata', 'App\Controller\IndataController@index', ['middleware' => [CorsMiddleware::class]]);

Router::addGroup('/{group_no}/', function () {
    Router::addRoute('POST', 'robots', 'App\Controller\SitemapController@robots');
    Router::addRoute('POST', 'map', 'App\Controller\SitemapController@map');
    Router::addRoute('POST', 'word', 'App\Controller\SitemapController@word');
    Router::addRoute('POST', 'jump', 'App\Controller\SitemapController@jump');
    Router::addRoute('POST', 'indata', 'App\Controller\IndataController@index');
    Router::addRoute('POST', 'beima1', 'App\Controller\SitemapController@beima1');
    Router::addRoute('POST', 'beima2', 'App\Controller\SitemapController@beima2');
}, ['middleware' => [CorsMiddleware::class]]);
